package com.myres.struts2.action;

import java.util.List;
import java.util.Set;

import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.ActionServletWrapper;
import org.springframework.context.ApplicationContext;

import com.myres.biz.ShopBiz;
import com.myres.dao.ProductDao;
import com.myres.dao.ShopDao;
import com.myres.model.Product;
import com.myres.model.Shop;
import com.myres.model.User;
import com.myres.service.ShopService;
import com.myres.spring.SpringUtils;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class GetAllProductAction extends ActionSupport {
	private User user;
	private List<Product> products;
	private ProductDao productDao;
	public ProductDao getProductDao() {
		return productDao;
	}
	public void setProductDao(ProductDao productDao) {
		this.productDao = productDao;
	}
	public GetAllProductAction(){
		super();
		System.out.println("constructor of GetAllProductAction");
	}
	public List<Product> getProducts() {
		return products;
	}
	public void setProducts(List<Product> products) {
		this.products = products;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	
	/**
	 * @return
	 */
	public String execute() {
		// TODO Auto-generated method stub
		products = productDao.findAll();
		System.out.println("has product ..."+products==null? null :products.size());
		return SUCCESS;
	}
	public String getNewArrivals(){
		products = productDao.findNewArrivals();
		System.out.println("getNewArrivalsz........................................"+products.size());
		return SUCCESS;
	}
}